import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {HeroesComponent} from './heroes/heroes.component';
import {DashboardComponent} from './dashboard/dashboard.component';
import {HeroDetailComponent} from './hero-detail/hero-detail.component';
import {ProductIndexComponent} from "./product-index/product-index.component";
import {ProductListComponent} from "./product-list/product-list.component";
import {ProductDetailComponent} from "./product-detail/product-detail.component";
import {ProductUserCenterComponent} from "./product-user-center/product-user-center.component";
import {ProductNotFoundComponent} from "./product-not-found/product-not-found.component";
import {MyIndexComponent} from "./my-index/my-index.component";
import {MyUserCenterComponent} from "./my-user-center/my-user-center.component";
import {MyNotFoundComponent} from "./my-not-found/my-not-found.component";
import {MyInfoComponent} from "./my-info/my-info.component";
import {AvatarComponent} from "./avatar/avatar.component";
import {SecurityComponent} from "./security/security.component";
import {LoginGuard} from "./login.guard";
import {TimeGuard} from "./time.guard";

let routes = [
  // { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
  // {path: 'dashboard', component: DashboardComponent},
  // {path: 'detail/:id', component: HeroDetailComponent},
  // {path: 'heroes', component: HeroesComponent},
  // {path: '', component: ProductUserCenterComponent},
  // {path: '', redirectTo: '/pindex', pathMatch: 'full'},
  // {path: 'pindex', component: ProductIndexComponent},
  // {path: 'plist', component: ProductListComponent},
  // {path: 'pdetail/:pid', component: ProductDetailComponent},
  // {path: 'pucenter', component: ProductUserCenterComponent},
  // {path: '**', component: ProductNotFoundComponent},
  {path: '', component: MyIndexComponent},
  {path: 'index', component: MyIndexComponent},
  {
    path: 'user/center',
    component: MyUserCenterComponent,
    canActivate: [LoginGuard, TimeGuard, LoginGuard],
    children: [
      {path: '', redirectTo: 'info', pathMatch: 'full'},
      {path: 'info', component: MyInfoComponent},
      {path: 'avatar', component: AvatarComponent},
      {path: 'security', component: SecurityComponent},
    ]
  },
  {path: '**', component: MyNotFoundComponent},
]

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {
}
